package com.szsfm.vehiclemanagement.mvp.model.modelImpl;

import android.text.TextUtils;

import com.szsfm.vehiclemanagement.VMApplication;
import com.szsfm.vehiclemanagement.bean.User;
import com.szsfm.vehiclemanagement.mvp.model.IUserLoginModel;
import com.szsfm.vehiclemanagement.tcp.TcpCore;
import com.szsfm.vehiclemanagement.tcp.TcpUtil;

/**
 * Created by zhoubigbo on 2017/11/29.
 */

public class UserLoginModelImpl implements IUserLoginModel {

    @Override
    public void userLogin(String username, String password,UserLoginListener listener) {
        if (TextUtils.isEmpty(username) || TextUtils.isEmpty(password)) {
            listener.loginFailed("用户名和密码不能为空");
            return;
        }
        User user = User.shareInstance();
        user.setUsername(username);
        user.setPassword(password);
        //开启长连接服务
        TcpCore.enableConn = true;
        TcpUtil.startSavService(VMApplication.getApplication());
    }
}
